package cn.tedu.hospital.admin.server.statistics.dao.persist.repository.impl;

import cn.tedu.hospital.admin.server.common.pojo.vo.PageData;
import cn.tedu.hospital.admin.server.common.util.PageInfoToPageDataConverter;
import cn.tedu.hospital.admin.server.statistics.dao.persist.mapper.PayDetailMapper;
import cn.tedu.hospital.admin.server.statistics.dao.persist.repository.IPayDetailRepository;
import cn.tedu.hospital.admin.server.statistics.pojo.vo.PayDetailStatisticsVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * 收费明细相关的数据访问实现类
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Slf4j
@Repository
public class PayDetailRepositoryImpl implements IPayDetailRepository {

    @Autowired
    private PayDetailMapper payDetailMapper;

    @Override
    public PageData<PayDetailStatisticsVO> listInPay(Integer pageNum, Integer pageSize) {
        log.debug("开始处理【收费明细列表查询】的数据访问，页码：{}，每页记录数：{}", pageNum, pageSize);
        PageHelper.startPage(pageNum, pageSize);
        List<PayDetailStatisticsVO> list = payDetailMapper.listInPay();
        PageInfo<PayDetailStatisticsVO> pageInfo = new PageInfo<>(list);
        PageData<PayDetailStatisticsVO> pageData = PageInfoToPageDataConverter.convert(pageInfo);

        return pageData;
    }

    @Override
    public PayDetailStatisticsVO PayByName(String name) {
        log.debug("开始处理【查询对应收费明细】的数据访问，病人姓名：{}", name);
        return payDetailMapper.PayByName(name);
    }

}
